package com.ruoyi.labsafety.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labsafety.domain.LabSafetyCheckTargetOrg;
import com.ruoyi.labsafety.service.ILabSafetyCheckTargetOrgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检查目标Controller
 * 
 * @author ruoyi
 * @date 2022-03-30
 */
@RestController
@RequestMapping("/labsafety/org")
public class LabSafetyCheckTargetOrgController extends BaseController
{
    @Autowired
    private ILabSafetyCheckTargetOrgService labSafetyCheckTargetOrgService;

    /**
     * 查询检查目标列表
     */
   // @PreAuthorize("@ss.hasPermi('labsafety:org:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabSafetyCheckTargetOrg labSafetyCheckTargetOrg)
    {
        startPage();
        List<LabSafetyCheckTargetOrg> list = labSafetyCheckTargetOrgService.selectLabSafetyCheckTargetOrgList(labSafetyCheckTargetOrg);
        return getDataTable(list);
    }

    /**
     * 导出检查目标列表
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:org:export')")
    @Log(title = "检查目标", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabSafetyCheckTargetOrg labSafetyCheckTargetOrg)
    {
        List<LabSafetyCheckTargetOrg> list = labSafetyCheckTargetOrgService.selectLabSafetyCheckTargetOrgList(labSafetyCheckTargetOrg);
        ExcelUtil<LabSafetyCheckTargetOrg> util = new ExcelUtil<LabSafetyCheckTargetOrg>(LabSafetyCheckTargetOrg.class);
        return util.exportExcel(list, "org");
    }

    /**
     * 获取检查目标详细信息
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:org:query')")
    @GetMapping(value = "/{checkTargtOrgId}")
    public AjaxResult getInfo(@PathVariable("checkTargtOrgId") Long checkTargtOrgId)
    {
        return AjaxResult.success(labSafetyCheckTargetOrgService.selectLabSafetyCheckTargetOrgById(checkTargtOrgId));
    }

    /**
     * 新增检查目标
     */
   // @PreAuthorize("@ss.hasPermi('labsafety:org:add')")
    @Log(title = "检查目标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabSafetyCheckTargetOrg labSafetyCheckTargetOrg)
    {
        return toAjax(labSafetyCheckTargetOrgService.insertLabSafetyCheckTargetOrg(labSafetyCheckTargetOrg));
    }

    /**
     * 修改检查目标
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:org:edit')")
    @Log(title = "检查目标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabSafetyCheckTargetOrg labSafetyCheckTargetOrg)
    {
        return toAjax(labSafetyCheckTargetOrgService.updateLabSafetyCheckTargetOrg(labSafetyCheckTargetOrg));
    }

    /**
     * 删除检查目标
     */
  //  @PreAuthorize("@ss.hasPermi('labsafety:org:remove')")
    @Log(title = "检查目标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkTargtOrgIds}")
    public AjaxResult remove(@PathVariable Long[] checkTargtOrgIds)
    {
        return toAjax(labSafetyCheckTargetOrgService.deleteLabSafetyCheckTargetOrgByIds(checkTargtOrgIds));
    }
}
